import { createStore } from 'vuex'
import http from '@/util/http'
export default createStore({
  state: {
    isShowNavBar:true,
    cityId: '310100',
    cityName: '上海',
    cinemaList: [],
  },
  getters: {
  },
  mutations: {
    isShow(state){
      state.isShowNavBar = true
    },
    isHidden(state){
      state.isShowNavBar = false
    },
    changeCinemaList(state,data){
      state.cinemaList = data
    },
    changeCityId(state,cityId){
      state.cityId = cityId
    },
    changeCityName(state,cityName){
      state.cityName = cityName
    },
  },
  actions: {
    getCinemaData(store,cityId){
      return http({
          url: `/gateway?cityId=${store.state.cityId}&ticketFlag=1&k=9025864`,
          headers: {
          'X-Host': 'mall.film-ticket.cinema.list',
          }
        }).then(res => {
            // console.log(res.data.data)
            store.commit("changeCinemaList", res.data.data.cinemas)
        })
        }
  },
  modules: {
  }
})
